package com.slz3.business.module.systemManagement.sysOrganize.domain;

import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.util.UUIDUtils;
import com.slz3.business.frame.util.VE;

import java.time.LocalDateTime;

public class SysOrganizeFactory {

    /**
     * 初始化基础属性值
     */
    public static SysOrganize initBaseFields(SysOrganize sysOrganize) {
        if (sysOrganize.getUuid() == null) {
            sysOrganize.setUuid(UUIDUtils.generateUUID());
            sysOrganize.setCreateTime(LocalDateTime.now());
            sysOrganize.setSerAudit(AuditFlag.APPROVED);
            if (VE.isEmpty(sysOrganize.getSerUsing())) {
                sysOrganize.setSerUsing(UsingFlag.ENABLE);
            }
        } else {
            sysOrganize.setLastModifyTime(LocalDateTime.now());
        }
        return sysOrganize;
    }

    /**
     * 初始化基础属性值
     */
    public static SysOrganize initBaseFields() {
        return initBaseFields(newTemStyle());
    }

    public static SysOrganize newTemStyle() {
        return new SysOrganize();
    }

}
